/*     */ package com.feeyin.radar.sys.controller;
/*     */ 
/*     */ import com.feeyin.radar.commons.Page;
/*     */ import com.feeyin.radar.commons.StringUtils;
/*     */ import com.feeyin.radar.crm.model.UserViewFunPosition;
/*     */ import com.feeyin.radar.sys.model.Role;
/*     */ import com.feeyin.radar.sys.service.FunctionTreeService;
/*     */ import com.feeyin.radar.sys.service.OperateService;
/*     */ import com.feeyin.radar.sys.service.RoleService;
/*     */ import com.feeyin.radar.sys.service.UserService;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import javax.servlet.http.HttpSession;
/*     */ import org.springframework.web.servlet.ModelAndView;
/*     */ import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
/*     */ import org.springframework.web.servlet.view.RedirectView;
/*     */ 
/*     */ public class RoleController extends MultiActionController
/*     */ {
/*     */   private RoleService roleService;
/*     */   private FunctionTreeService functionTreeService;
/*     */   private OperateService operateService;
/*     */   private UserService userService;
/*     */   private String roleManage;
/*     */   private String addRole;
/*     */   private String updateRole;
/*     */   private String viewRole;
/*     */   private String viewRoleUser;
/*     */   private String addViewRole;
/*     */   private String updateViewRole;
/*     */ 
/*     */   public String getAddViewRole()
/*     */   {
/*  44 */     return this.addViewRole;
/*     */   }
/*     */   public void setAddViewRole(String addViewRole) {
/*  47 */     this.addViewRole = addViewRole;
/*     */   }
/*     */   public String getUpdateViewRole() {
/*  50 */     return this.updateViewRole;
/*     */   }
/*     */   public void setUpdateViewRole(String updateViewRole) {
/*  53 */     this.updateViewRole = updateViewRole;
/*     */   }
/*     */   public RoleService getRoleService() {
/*  56 */     return this.roleService;
/*     */   }
/*     */   public void setRoleService(RoleService roleService) {
/*  59 */     this.roleService = roleService;
/*     */   }
/*     */ 
/*     */   public FunctionTreeService getFunctionTreeService() {
/*  63 */     return this.functionTreeService;
/*     */   }
/*     */   public void setFunctionTreeService(FunctionTreeService functionTreeService) {
/*  66 */     this.functionTreeService = functionTreeService;
/*     */   }
/*     */ 
/*     */   public OperateService getOperateService() {
/*  70 */     return this.operateService;
/*     */   }
/*     */   public void setOperateService(OperateService operateService) {
/*  73 */     this.operateService = operateService;
/*     */   }
/*     */ 
/*     */   public UserService getUserService() {
/*  77 */     return this.userService;
/*     */   }
/*     */   public void setUserService(UserService userService) {
/*  80 */     this.userService = userService;
/*     */   }
/*     */   public String getRoleManage() {
/*  83 */     return this.roleManage;
/*     */   }
/*     */ 
/*     */   public void setRoleManage(String roleManage) {
/*  87 */     this.roleManage = roleManage;
/*     */   }
/*     */ 
/*     */   public String getAddRole() {
/*  91 */     return this.addRole;
/*     */   }
/*     */   public void setAddRole(String addRole) {
/*  94 */     this.addRole = addRole;
/*     */   }
/*     */ 
/*     */   public String getUpdateRole() {
/*  98 */     return this.updateRole;
/*     */   }
/*     */   public void setUpdateRole(String updateRole) {
/* 101 */     this.updateRole = updateRole;
/*     */   }
/*     */   public String getViewRole() {
/* 104 */     return this.viewRole;
/*     */   }
/*     */   public void setViewRole(String viewRole) {
/* 107 */     this.viewRole = viewRole;
/*     */   }
/*     */ 
/*     */   public String getViewRoleUser() {
/* 111 */     return this.viewRoleUser;
/*     */   }
/*     */   public void setViewRoleUser(String viewRoleUser) {
/* 114 */     this.viewRoleUser = viewRoleUser;
/*     */   }
/*     */ 
/*     */   public ModelAndView display(HttpServletRequest request, HttpServletResponse response) {
/* 118 */     Map map = new HashMap();
/* 119 */     map.put("result", request.getParameter("result"));
/*     */ 
/* 121 */     List roles = new ArrayList();
/* 122 */     roles = this.roleService.getRoles();
/* 123 */     map.put("roles", roles);
/*     */ 
/* 125 */     return new ModelAndView(getRoleManage(), map);
/*     */   }
/*     */ 
/*     */   public ModelAndView viewRole(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 130 */     Map map = new HashMap();
/*     */ 
/* 132 */     List functions = new ArrayList();
/* 133 */     functions = this.functionTreeService.getFunctionsByActivity();
/* 134 */     map.put("functions", functions);
/*     */ 
/* 136 */     List operates = new ArrayList();
/* 137 */     operates = this.operateService.getOperatesByActivity();
/* 138 */     map.put("operates", operates);
/*     */ 
/* 140 */     String id = request.getParameter("id");
/* 141 */     String funcOperateIds = "";
/* 142 */     if (!StringUtils.isEmpty(id)) {
/* 143 */       map.put("role", this.roleService.getRole(Integer.valueOf(Integer.parseInt(id))));
/*     */ 
/* 145 */       funcOperateIds = this.roleService.getFunctionIdsOperateIdsByRoleId(Integer.valueOf(Integer.parseInt(id)));
/* 146 */       map.put("funcOperateIds", funcOperateIds);
/*     */     }
/*     */ 
/* 149 */     return new ModelAndView(getViewRole(), map);
/*     */   }
/*     */ 
/*     */   public ModelAndView viewRoleUsers(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 154 */     String roleId = request.getParameter("roleId");
/*     */ 
/* 156 */     Map map = new HashMap();
/* 157 */     map.put("roleId", roleId);
/*     */ 
/* 159 */     if (!StringUtils.isEmpty(roleId)) {
/* 160 */       Page page = new Page();
/* 161 */       page.getPageList(this.userService.getPageUsersCountByRoleId(Integer.valueOf(Integer.parseInt(roleId))).intValue(), null, request);
/*     */ 
/* 163 */       List users = new ArrayList();
/* 164 */       users = this.userService.getPageUsersByRoleId(Integer.valueOf(Integer.parseInt(roleId)), page);
/* 165 */       map.put("users", users);
/*     */     }
/* 167 */     return new ModelAndView(getViewRoleUser(), map);
/*     */   }
/*     */ 
/*     */   public ModelAndView preAddRole(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 172 */     Map map = new HashMap();
/* 173 */     map.put("result", request.getParameter("result"));
/* 174 */     map.put("repeat", request.getAttribute("repeat"));
/* 175 */     map.put("roleCode", this.roleService.getRoleCode());
/*     */ 
/* 177 */     List functions = new ArrayList();
/* 178 */     functions = this.functionTreeService.getFunctionsByActivity();
/* 179 */     map.put("functions", functions);
/*     */ 
/* 181 */     List operates = new ArrayList();
/* 182 */     operates = this.operateService.getOperatesByActivity();
/* 183 */     map.put("operates", operates);
/*     */ 
/* 185 */     return new ModelAndView(getAddRole(), map);
/*     */   }
/*     */ 
/*     */   public ModelAndView addRole(HttpServletRequest request, HttpServletResponse response, Role role)
/*     */   {
/* 190 */     String[] cFunctions = request.getParameterValues("cFunction");
/* 191 */     String[] cOperates = request.getParameterValues("cOperate");
/*     */ 
/* 193 */     boolean result = false;
/* 194 */     int success = 0;
/*     */ 
/* 196 */     if (this.roleService.getRoleByRoleName(role.getRoleName()) != null) {
/* 197 */       request.setAttribute("repeat", Integer.valueOf(1));
/* 198 */       request.setAttribute("role", role);
/* 199 */       return preAddRole(request, response);
/*     */     }
/*     */ 
/* 202 */     result = this.roleService.insertRole(role, cFunctions, cOperates);
/* 203 */     if (result) success = 1;
/*     */ 
/* 205 */     return new ModelAndView(new RedirectView("./role.do?action=preAddRole&result=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView preUpdateRole(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 210 */     Map map = new HashMap();
/* 211 */     map.put("result", request.getParameter("result"));
/* 212 */     map.put("repeat", request.getAttribute("repeat"));
/*     */ 
/* 214 */     List functions = new ArrayList();
/* 215 */     functions = this.functionTreeService.getFunctionsByActivity();
/* 216 */     map.put("functions", functions);
/*     */ 
/* 218 */     List operates = new ArrayList();
/* 219 */     operates = this.operateService.getOperatesByActivity();
/* 220 */     map.put("operates", operates);
/*     */ 
/* 222 */     String id = request.getParameter("id");
/* 223 */     String funcOperateIds = "";
/* 224 */     if (!StringUtils.isEmpty(id)) {
/* 225 */       map.put("role", this.roleService.getRole(Integer.valueOf(Integer.parseInt(id))));
/*     */ 
/* 227 */       funcOperateIds = this.roleService.getFunctionIdsOperateIdsByRoleId(Integer.valueOf(Integer.parseInt(id)));
/* 228 */       map.put("funcOperateIds", funcOperateIds);
/*     */     }
/* 230 */     return new ModelAndView(getUpdateRole(), map);
/*     */   }
/*     */ 
/*     */   public ModelAndView updateRole(HttpServletRequest request, HttpServletResponse response, Role role)
/*     */   {
/* 235 */     String[] cFunctions = request.getParameterValues("cFunction");
/* 236 */     String[] cOperates = request.getParameterValues("cOperate");
/*     */ 
/* 238 */     boolean result = false;
/* 239 */     int success = 0;
/*     */ 
/* 241 */     if (this.roleService.isRepeatUpdateRole(role)) {
/* 242 */       request.setAttribute("repeat", Integer.valueOf(1));
/* 243 */       request.setAttribute("role", role);
/* 244 */       return preUpdateRole(request, response);
/*     */     }
/*     */ 
/* 247 */     result = this.roleService.updateRole(role, cFunctions, cOperates);
/* 248 */     if (result) success = 1;
/*     */ 
/* 250 */     return new ModelAndView(new RedirectView("./role.do?action=preUpdateRole&result=" + success + "&id=" + role.getId()));
/*     */   }
/*     */ 
/*     */   public ModelAndView updateViewRole(HttpServletRequest request, HttpServletResponse response, Role role) {
/* 254 */     String[] functions = request.getParameterValues("ck");
/* 255 */     boolean result = false;
/* 256 */     int success = 0;
/*     */ 
/* 258 */     if (this.roleService.isRepeatUpdateRole(role)) {
/* 259 */       request.setAttribute("repeat", Integer.valueOf(1));
/* 260 */       request.setAttribute("role", role);
/* 261 */       return preUpdateRole(request, response);
/*     */     }
/* 263 */     result = this.roleService.updateRole(role, functions);
/* 264 */     if (result) success = 1;
/*     */ 
/* 267 */     return new ModelAndView(new RedirectView("./role.do?action=preUpdateViewRole&result=" + success + "&id=" + role.getId()));
/*     */   }
/*     */ 
/*     */   public ModelAndView deleteRole(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 272 */     boolean result = false;
/* 273 */     int success = 0;
/*     */ 
/* 275 */     String[] ids = request.getParameterValues("roleId");
/* 276 */     result = this.roleService.deleteRoles(ids);
/* 277 */     if (result) success = 1;
/*     */ 
/* 279 */     return new ModelAndView(new RedirectView("./role.do?action=display&result=" + success));
/*     */   }
/*     */ 
/*     */   public ModelAndView preAddViewRole(HttpServletRequest request, HttpServletResponse response) {
/* 283 */     return null;
/*     */   }
/*     */   public ModelAndView preUpdateViewRole(HttpServletRequest request, HttpServletResponse response) {
/* 286 */     Map map = new HashMap();
/* 287 */     map.put("result", request.getParameter("result"));
/* 288 */     map.put("repeat", request.getAttribute("repeat"));
/*     */ 
/* 290 */     List viewFunctions = new ArrayList();
/* 291 */     viewFunctions = this.functionTreeService.getViewFunctions();
/* 292 */     map.put("functions", viewFunctions);
/* 293 */     String id = request.getParameter("id");
/* 294 */     String funcIds = "";
/* 295 */     if (!StringUtils.isEmpty(id)) {
/* 296 */       map.put("role", this.roleService.getRole(Integer.valueOf(Integer.parseInt(id))));
/* 297 */       funcIds = this.roleService.getViewFunctionIdsByRoleId(Integer.valueOf(Integer.parseInt(id)));
/* 298 */       map.put("funcOperateIds", funcIds);
/*     */     }
/* 300 */     return new ModelAndView(getUpdateViewRole(), map);
/*     */   }
/*     */ 
/*     */   public ModelAndView addUserViewFunPosition(HttpServletRequest request, HttpServletResponse response) {
/* 304 */     Integer userId = (Integer)request.getSession().getAttribute("userId");
/*     */ 
/* 306 */     Integer viewMagId1 = Integer.valueOf(Integer.parseInt(request.getParameter("viewId1")));
/* 307 */     Integer viewMagId2 = Integer.valueOf(Integer.parseInt(request.getParameter("viewId2")));
/* 308 */     Integer viewMagId3 = Integer.valueOf(Integer.parseInt(request.getParameter("viewId3")));
/* 309 */     Integer viewMagId4 = Integer.valueOf(Integer.parseInt(request.getParameter("viewId4")));
/* 310 */     Integer viewMagId5 = Integer.valueOf(Integer.parseInt(request.getParameter("viewId5")));
/* 311 */     Integer viewMagId6 = Integer.valueOf(Integer.parseInt(request.getParameter("viewId6")));
/* 312 */     Integer viewMagId7 = Integer.valueOf(Integer.parseInt(request.getParameter("viewId7")));
/* 313 */     Integer viewMagId8 = Integer.valueOf(Integer.parseInt(request.getParameter("viewId8")));
/* 314 */     List list = new ArrayList();
/*     */ 
/* 316 */     if (viewMagId1.intValue() != 0) {
/* 317 */       UserViewFunPosition uv1 = new UserViewFunPosition();
/* 318 */       uv1.setUserId(userId);
/* 319 */       uv1.setViewMagId(viewMagId1);
/* 320 */       uv1.setSignId(Integer.valueOf(1));
/* 321 */       uv1.setPositionId(Integer.valueOf(1));
/* 322 */       list.add(uv1);
/*     */     }
/* 324 */     if (viewMagId2.intValue() != 0) {
/* 325 */       UserViewFunPosition uv2 = new UserViewFunPosition();
/* 326 */       uv2.setUserId(userId);
/* 327 */       uv2.setViewMagId(viewMagId2);
/* 328 */       uv2.setSignId(Integer.valueOf(1));
/* 329 */       uv2.setPositionId(Integer.valueOf(2));
/* 330 */       list.add(uv2);
/*     */     }
/* 332 */     if (viewMagId3.intValue() != 0) {
/* 333 */       UserViewFunPosition uv3 = new UserViewFunPosition();
/* 334 */       uv3.setUserId(userId);
/* 335 */       uv3.setViewMagId(viewMagId3);
/* 336 */       uv3.setSignId(Integer.valueOf(1));
/* 337 */       uv3.setPositionId(Integer.valueOf(3));
/* 338 */       list.add(uv3);
/*     */     }
/* 340 */     if (viewMagId4.intValue() != 0) {
/* 341 */       UserViewFunPosition uv4 = new UserViewFunPosition();
/* 342 */       uv4.setUserId(userId);
/* 343 */       uv4.setViewMagId(viewMagId4);
/* 344 */       uv4.setSignId(Integer.valueOf(1));
/* 345 */       uv4.setPositionId(Integer.valueOf(4));
/* 346 */       list.add(uv4);
/*     */     }
/* 348 */     if (viewMagId5.intValue() != 0) {
/* 349 */       UserViewFunPosition uv5 = new UserViewFunPosition();
/* 350 */       uv5.setUserId(userId);
/* 351 */       uv5.setViewMagId(viewMagId5);
/* 352 */       uv5.setSignId(Integer.valueOf(2));
/* 353 */       uv5.setPositionId(Integer.valueOf(5));
/* 354 */       list.add(uv5);
/*     */     }
/* 356 */     if (viewMagId6.intValue() != 0) {
/* 357 */       UserViewFunPosition uv6 = new UserViewFunPosition();
/* 358 */       uv6.setUserId(userId);
/* 359 */       uv6.setViewMagId(viewMagId6);
/* 360 */       uv6.setSignId(Integer.valueOf(2));
/* 361 */       uv6.setPositionId(Integer.valueOf(6));
/* 362 */       list.add(uv6);
/*     */     }
/* 364 */     if (viewMagId7.intValue() != 0) {
/* 365 */       UserViewFunPosition uv7 = new UserViewFunPosition();
/* 366 */       uv7.setUserId(userId);
/* 367 */       uv7.setViewMagId(viewMagId7);
/* 368 */       uv7.setSignId(Integer.valueOf(2));
/* 369 */       uv7.setPositionId(Integer.valueOf(7));
/* 370 */       list.add(uv7);
/*     */     }
/* 372 */     if (viewMagId8.intValue() != 0) {
/* 373 */       UserViewFunPosition uv8 = new UserViewFunPosition();
/* 374 */       uv8.setUserId(userId);
/* 375 */       uv8.setViewMagId(viewMagId8);
/* 376 */       uv8.setSignId(Integer.valueOf(2));
/* 377 */       uv8.setPositionId(Integer.valueOf(8));
/* 378 */       list.add(uv8);
/*     */     }
/* 380 */     this.roleService.addUserViewFunPosition(userId, list);
/* 381 */     return new ModelAndView(new RedirectView("./index.do?action=mainPage"));
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.sys.controller.RoleController
 * JD-Core Version:    0.6.0
 */